home *** CD-ROM | disk | FTP | other *** search
- Path: news.cyberport.com!usenet
- From: tangent@cyberport.com (Warren Young)
- Newsgroups: comp.lang.c++
- Subject: Re: C vs Pascal
- Date: Sun, 28 Jan 1996 00:34:54 GMT
- Organization: ETR..., Inc.
- Message-ID: <310ab831.512924160@news.cyberport.com>
- References: <8B87053.0054014A15.uuout@swcbbs.com> <8B8F52F.0054014CDF.uuout@swcbbs.com> <4e0huu$rhn@classic.iinet.com.au>
- NNTP-Posting-Host: ppp1.cyberport.com
- X-Newsreader: Forte Agent .99c/16.141
-
- ng@mitswa.com.au (John A Ng) wrote:
-
- >In such as argument, we should really be objective and see why C is
- >actually more popular than it should.
- >
- >1. C is portable. Many people think C is portable in that it can be
- >taken from one platform and compile in another. That is incorrect since
- >very very few programs written in C are fully portable except the
- >absurdly small.
-
- Of course, but that's not the point. The point is that you can write
- a program in C whose core logic and routines are completely portable.
- Standard Pascal is more or less useless; so, to make it useful,
- Borland has greatly extended Turbo Pascal beyond the "standard"
- definition of Pascal. But because none of these extensions have been
- standardized (except by fiat), TP code generally isn't portable. On
- the other hand, C is a powerful language to start with, so portable
- programs can be written in it without straying from the standard
- language.
-
- Now that C++ is more or less "here", we also have encapsulation as a
- portability tool. It lets us hide platform-specific details behind a
- class interface. Want to add another platform? Add another class
- whose interface is the same as the others'. You could do this in C,
- too, by placing "compatibility" functions in a single module, and
- writing a module for each platform you want to support. Then, at
- compile time, compile the right module for the current platform, and
- link it in.
-
- The C standard also defines standard methods for conditional
- compilation. This lets you have a single section of source whose
- behavior changes depending on compile-time options, letting you change
- platforms by recompiling. Most "portable" programs use this
- technique.
-
- Sure, TP has many of these features, but none are portable. You
- couldn't, for example, write TP code that would properly recompile on
- Pascal for the DEC Alpha based on compile-time options.
-
- >for the learner because Turbo Pascal is lightning fast. Many
- >professional programs are developed in Turbo Pascal!!!
-
- As long as you only plan on supporting DOS and Windows, TP is a good
- choice.
-
- There _are_ hidden problems with this, though. Your program may not
- need to be portable, but wouldn't it be nice if _others'_ programs
- were portable to _your_ platform? Specifically, TP's nonportability
- means that it is open to fewer programmers, which means that there are
- fewer "freeware" modules floating around for you to use in your own
- code. The TP world's crown jewel in this area is the SWAG collection.
- C/C++ has at least two: Snippets, and the alt.sources archives. Plus,
- there are _many_ more independent libraries available. Just take a
- look at the "libraries" FAQ posted to comp.lang.c++ periodically.
-
- Then there's the commercial market: more user support means more
- vendor support, which means more third-party libraries. Does TP have
- anything even close to the power of Rogue Wave's tools.h++?
-
- So, portability influences a lot more than the number of platforms you
- can code for.
-
- >2. C is more efficient. Bullshit. C/C++ with all its standards is
- >absurdly inefficient in terms of development time. C headers compiles
- >and compiles again for no apparent reason. You must employ tricks to
- >prevent the recompile.
-
- This is a function of your environment, not the language itself. We
- can talk "implementation" until the sun stops fusing, and we'll get
- nowhere. If you need a faster recompile, get more MIPS or jump ship
- to a vendor whose compile times are lower.
-
- However, it's clear that you don't really understand your environment.
- Headers don't "recompile for no apparent reason". They recompile
- because something they depend on has changed. If you don't want this
- sort of thing to happen, you have to reduce your header
- interdependencies. Ask yourself, does this file _really_ need to
- include this header? There are many legal and acceptable "tricks" to
- reduce this.
-
- You can't properly criticize something you don't understand.
-
- >don't want to comment. Turbo Pascal, on the other hand, is the most
- >efficient compiler on earth. It makes any C compiler cry!!! -- A
- >staggering 20 to 1 ratio!!! This is because there are no standards for
- >Turbo Pascal and Borland is free to optimize the languge and features as
- >it sees fit.
-
- And when you're done, you get an executable that's either much bigger
- or much slower (I don't know which). C compilers, on the other hand,
- spend more time optimizing, resulting in smaller, faster executables.
- _This_ is what we mean when we say "efficient". End users don't give
- a darn how long it took to compile the program if the result is bigger
- or slower than a competing program written in a more "efficient"
- language.
-
- >5. C and Pascal are similar. True, Turbo Pascal could properly be
- >called a dialect of C. However, the latest reincarnation of Turbo
- >Pascal (called Delphi) includes many Smalltalk concepts.
- >
- >6. C is always way ahead (better designed) than Pascal. Incorrect.
- >C++ has incorporated things from Pascal like variable parameters (ie
- >passing by reference). C++ also lacks proper string facility.
-
- C++ did _not_ inherit pass-by-reference from Pascal. Sure, Pascal had
- a similar mechanism first, but C has always had pointers, which is
- what the code compiles to anyway. References are just syntactic sugar
- for pointers, and they were added to C++ to make operator overloading
- transparent.
-
- Let's turn the tables, though, and see how many things TP swiped from
- C/C++:
-
- o Classes (or whatever TP with Objects calls them)
-
- o Free-form declarations -- standard Pascal requires that your
- declarations be segregated by type, with only one type group at each
- level of scope.
-
- o Bitwise operators
-
- o Separate compilation (UNITs and modules)
-
- o Conditional compilation
-
- What has C/C++ still got that TP doesn't?
-
- o Multiple inheritance
-
- o Variable-length argument lists
-
- o Forward references and prototypes. Functions don't have to be in a
- specific order in C/C++.
-
- o A more powerful base language -- Try writing writeln() in Pascal
- sometime. You can't do it because the language doesn't support vararg
- functions, so the language had to have that function defined into it.
- Same goes for ord() and more. None of the functions in the C/C++
- standard are built into the language, because they don't have to be.
-
- o Pointer arithmetic -- try writing strcpy() in Pascal. Or anything
- else that manipulates blocks of memory. Related to this is that,
- because the size of an array is a part of its type, you can't have
- general-purpose memory-block manipulation routines.
-
- And to be fair, there is at least one thing Pascal has that C/C++
- doesn't: nested procedures. Whoop!
-
- >(PS: I am a profession C++ programmer who started with Turbo Pascal).
-
- I am a professional C++ programmer who started with ISO Pascal, and
- have had many similar discussions with your fellow TPers. I remain
- unconvinced.
-
- = Warren --
-